<?php

/**
 * players actions.
 *
 * @package    dylemat
 * @subpackage players
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class playersActions extends sfActions {

    /**
     * Executes index action
     *
     * @param sfRequest $request A request object
     */
    public function executeIndex(sfWebRequest $request) {
        $this->forward404Unless($this->getUser()->isAdmin());
        $this->page = ($request->getParameter('page') == null) ? 1 : $request->getParameter('page');
    }

    public function executeSetPermission(sfWebRequest $request) {
        $this->forward404Unless($this->getUser()->isAdmin());
        $c = new Criteria();
        $c->add(playerPeer::ID, $request->getParameter('id'));

        switch ($request->getParameter('p')) {
            case 3:
                $c->add(playerPeer::MOD, 0);
                $c->add(playerPeer::ADMIN, 0);
                break;
            case 2:
                $c->add(playerPeer::MOD, 1);
                $c->add(playerPeer::ADMIN, 0);
                break;
            case 1:
                $c->add(playerPeer::MOD, 0);
                $c->add(playerPeer::ADMIN, 1);
                break;
        }
        playerPeer::doUpdate($c);
        $this->redirect('@players');
    }

}
